/******************************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Ltd.                       */
/*                                                                            */
/*  NAME      = informix_init.c                                               */
/*  NOTE      =                                                               */
/*  DATE      = 2015/08/25 by zhengxd                                         */
/******************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "frcomm.h"
#include "frmem.h"
#include "frstr.h"
#include "frlog.h"

#include "conntrack.h"
#include "module.h"
#include "frversion.h"

#include "config.h"
#include "informix_core.h"

//框架的上下文引用
void *g_p_apm_context=NULL;

#ifdef __cplusplus
extern "C"
{
#endif
/*******************************************************************************
*  FUNC     :  informix初始化
*  ARGS     :  p_context                    框架的上下文引用
*           :  p_module_params              模块入力参数
*           :  p_module_cfg                 模块配置信息出力
*  RTN      :  FR_FAIL
*           :  FR_SUCC
*  NOTE     :
*******************************************************************************/
int module_init(void *p_context, const char* p_module_params, L7_module_config *p_module_cfg)
{
    int i_ret_fun = FR_SUCC;
    
    if(p_context == NULL || p_module_params == NULL || p_module_cfg == NULL)
        return FR_FAIL;
    
    g_p_apm_context = p_context;
    if( fr_slab_init( (Frmem_env *)(((ApmContext *)g_p_apm_context)->p_st_mem_env), MODULE_NAME) == NULL )
    {
        return FR_FAIL;
    }

    frlog_set_hd(((ApmContext *)g_p_apm_context)->p_st_log_category);
    p_module_cfg->p_l4_proto = MODULE_L4PROTO;
    p_module_cfg->i_l7_proto = MODULE_L7PROTO;
    p_module_cfg->p_module_name = MODULE_NAME;
    p_module_cfg->p_version = MODULE_VERSION " " MODULE_TIME;
    p_module_cfg->l7_detect = informix_detect;
    p_module_cfg->l7_analysis = informix_analysis;
    p_module_cfg->session_destory = informix_session_destroy;
    
    return FR_SUCC;
}

/*******************************************************************************
*  FUNC     :  informix销毁
*  ARGS     :  void
*  RTN      :
*  NOTE     :
*******************************************************************************/
void module_exit(void)
{
    frdbg("informix_destroy\n");
    fr_slab_destroy();

    return;
}
#ifdef __cplusplus
}
#endif
